package com.twu.biblioteca;

public class UserCollection {
    private final User[] users;

    public UserCollection(User... users) {
        this.users = users;
    }

    public User checkUser(String id, String password) {
        for (User user : users) {
            if (user.matches(id, password)) {
                return user;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        for (User user : users) {
            stringBuilder.append(user);
        }
        return stringBuilder.toString();
    }
}
